Code
import numpy as np
import matplotlib.pyplot as plt
t_sim = np.arange(100) # 100 pasos
n_series = range(1, 4) # 3 series (1, 2, 3)
random_y = {}
for i in n_series:
y_t = []
for t in range(len(t_sim)):
e = np.random.normal(0, 1)
if t == 0:
y_t.append(e)
else:
y_t.append(y_t[t - 1] + e)
random_y[f"y_{i}"] = y_t
# 2. Graficamos
fig, ax = plt.subplots(figsize=(10, 5))
for key, value in random_y.items():
ax.plot(t_sim, value, label=key)
ax.set_title('Distintas realizaciones Y_t')
ax.set_xlabel('Tiempo')
ax.set_ylabel('y_t')
ax.legend()
ax.grid(True, alpha=0.3)
plt.show()